﻿using System.Windows;
using System.Threading;

namespace P2.Cuberry
{
    /// <summary>
    /// Interaction logic for Splash.xaml
    /// </summary>
    public partial class CuberrySplash : Window
    {
        private static CuberrySplash splash = new CuberrySplash();
        
        
        // To refresh the UI immediately
        private delegate void RefreshDelegate();
        

        public CuberrySplash()
        {
            InitializeComponent();
        }


        private static void Refresh(DependencyObject obj)
        {
            obj.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Render,
                (RefreshDelegate)delegate { });
        }



        public static void BeginDisplay()        
        {
            splash.Show();            
            CuberrySplash.Loading("Initializing...");
            Thread.Sleep(1500);
        }

        
        public static void EndDisplay()        
        {            
            splash.Close();                       
        }


        public static void Loading(string test)
        {
            splash.statuslbl.Content = test;
            Refresh(splash.statuslbl);            
        }

     

        


    }
}
